function [out] = param4evolution(p,n)
% Takes a structure of paramaters, p, means, standard deviations, and 
% minimum allowed values in order to calculate n cases.

if nargin == 0
    % Test case if no input
    p.a = [1 4 .1];
    p.b = 4;
    p.c = [10 4];
    n = 20;
end

% Initialize
out = [];
NameOfFields = fieldnames(p);

% Create n structures based on statistics in p in variable out
for jj = 1:n
    out{jj}=[];
    for ii = 1:length(NameOfFields)
        temp = getfield(p,NameOfFields{ii});
        if numel(temp)==1
            out{jj} = setfield(out{jj},NameOfFields{ii},temp);
        else
            temp2 = temp(1)+randn*temp(2); % Creates random value
            if (numel(temp)>2) && (temp2 < temp(3)) % Checks if random value is below minimum allowed value
                temp2 = temp(3);
            end
            out{jj} = setfield(out{jj},NameOfFields{ii},temp2);
        end
    end
end

end
